package com.star.gateway.biz;

import com.star.common.core.utils.BeanKit;
import com.star.gateway.contract.command.DemoDeleteCommand;
import com.star.gateway.contract.command.DemoSaveCommand;
import com.star.gateway.contract.command.DemoUpdateCommand;
import com.star.gateway.repository.model.DemoBO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @Author zhouhengzhe
 * @Desc Demo仓库，主要是给人去学习用(Demo)表领域处理服务类，用于gateway领域的增删改领域
 * @Date 2023-12-01 17:25:30
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class DemoService {

    /**
     * 保存gateway
     *
     * @param gatewaySaveCommand gateway请求体
     */
    public void save(DemoSaveCommand gatewaySaveCommand) {
        BeanKit.copy(gatewaySaveCommand, DemoBO.class).save();
    }

    /**
     * 删除gateway
     *
     * @param gatewayDeleteCommand 删除请求体
     */
    public void removeDemo(DemoDeleteCommand gatewayDeleteCommand) {
        DemoBO.repository().delete(gatewayDeleteCommand.getId());
    }

    /**
     * 更新gateway
     * @param gatewayUpdateCommand 更新请求体
     */
    public void updateDemo(DemoUpdateCommand gatewayUpdateCommand) {
        BeanKit.copy(gatewayUpdateCommand, DemoBO.class).update();
    }

}
